<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<title>老zk管理</title>
	</head>
	<body>
		<table id="searchResult"></table>
		<textarea id="node" rows="10" cols="40" style="display:none"></textarea>
		<input id="submit" type="button" display="hidden" value="提交"/>
    <script src="js/jquery.min.js"></script>
    <script src="js/DataInterface/DataInterface.js"></script>
    <script>
    function GetQueryString(name)
    {
         var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
         var r = window.location.search.substr(1).match(reg);
         if(r!=null)return  unescape(r[2]); return null;
    }
    $(function() {
        var num=GetQueryString('path');
   		var path = num == null ? '/' : num;
        $.ajax({
        	url : DI.baseURL + "/cache/queryZkList.do",
        	type : 'POST',
			data : {path : path},
			success:function(json) {
				var data = $.parseJSON(json);
				if (data != null) {
					var len = data.length;
					var rows = data;
					var htmlStr = '';
					for (var i = 0; i < len; i++) {
						if (rows[i].hasChildren) {
							htmlStr += ('<tr><td><a target="_blank" href="' + DI.baseURL 
									+ '/adminPage/assistant/oldZkManage.html?path=' + rows[i].id + '">'+rows[i].id+'</a></td></tr>');
						} else {
							htmlStr = '节点名'+rows[i].id;
							$('#node').text(rows[i].data);
							$('#node').show();
							$('#submit').show();
						}
					}
					$('#searchResult').html(htmlStr);
				} else {
					alert('查询失败');
				}
			}
        });
        $('#submit').click(function(){
        	$.ajax({
        		url : DI.baseURL + "/cache/saveZk.do",
            	type : 'POST',
    			data : {path : path, node:$('#node').val()},
    			success:function(json) {
    				var data = $.parseJSON(json);
    				if (data == '1') {
    					alert('修改成功');
    				}
    			}
        	});
        });
    });
    </script>
	</body>
</html>